import ajax from '../../utils/ajax';

const form = document.forms.login;

form.onsubmit = form_submit;


/**
 * 
 */
function form_submit(e) {
  e.preventDefault();
  ajax('post', '/api/userlogin', {
    uid: form.uid.value,
    pwd: form.pwd.value,
  }).then(result => {
    if (result.flag) {
      localStorage.setItem('token', result.data.token);
      alert(result.msg)
      location.replace('../../index.html')
    } else {
      alert(result.msg)
      form.uid.select()
    }


  })
}